<template>
	<view class="content">
		<view class="user_info">
			<image class="user_info_pic" :src="avatar" />
			<view class="user_info_name">{{name}}</view>
		</view>
		<view class="logout_btn">
			<wd-button block @click="handleLogout">退出</wd-button>
		</view>
	</view>

</template>

<script setup>
	import useUserStore from '@/store/modules/user'

	import {
		reactive,
		toRefs,
		getCurrentInstance
	} from 'vue';

	const {
		proxy
	} = getCurrentInstance()
	const {
		id,
		avatar,
		name,
	} = useUserStore()

	function handleLogout() {
		proxy.$modal.confirm('确定要退出登录吗？').then(() => {
			useUserStore().logOut().then(() => {
				proxy.$tab.reLaunch('/pages/login');
			});
		});
	}
</script>

<style lang="scss" scoped>
	.user_info {
		height: 36vh;
		position: relative;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;

		&::before {
			content: '';
			display: block;
			width: 100%;
			height: 47vh;
			background: linear-gradient(126deg, #93abdc 3%, #edf0f6 48%, #9dddf8 75%);
			position: absolute;
			top: 0;
			left: 0;
			mask-image: linear-gradient(to top, transparent, black 50%);
			mask: cover;
			z-index: -1;
		}

		&_pic {
			height: 196rpx;
			width: 196rpx;
		}

		&_name {
			font-weight: 600;
			margin-top: 24rpx;
		}
	}

	.logout_btn {
		position: absolute;
		bottom: 8vh;
		left: 50%;
		transform: translate(-50%, -50%);
		margin: 0 auto;
		width: 80vw;
	}
</style>